﻿var TAG_VERSION = "<version>";
var TAG_PHONE = "<phone>";
var TAG_ACCOUNTID = "<accountId>";
var TAG_USERID = "<userid>";
var TAG_LNG = "<lng>";
var TAG_LAT = "<lat>";

//http://test.com/theurl?a=<userid>&b=<lng>&c=<lat>"

//url里面占位符处理
function replaceUrl(stringUrl) {
    if (stringUrl != null) {// 替换URL中的参数
        if (stringUrl.indexOf(TAG_ACCOUNTID)>0) {// 用户ID
            stringUrl = stringUrl.replace(TAG_ACCOUNTID, accountId);
        }
        if (stringUrl.indexOf(TAG_VERSION)>0) {// 版本
            stringUrl = stringUrl.replace(TAG_VERSION, version);
        }

        if (stringUrl.indexOf(TAG_PHONE)>0) {// 电话
            stringUrl = stringUrl.replace(TAG_PHONE, userPhone);
        }

        if (stringUrl.indexOf(TAG_USERID) > 0) {
            stringUrl = stringUrl.replace(TAG_USERID, accountId);
        }

        if (stringUrl.indexOf(TAG_LNG) > 0) {
            stringUrl = stringUrl.replace(TAG_LNG, "");
        }
        if (stringUrl.indexOf(TAG_LAT) > 0) {
            stringUrl = stringUrl.replace(TAG_LAT, "");
        }
    }
    return stringUrl;
}